/**
 * jeDate 演示
 */
$(function () {
    //常规选择  certificationTime
    $("#insurersLowTime").jeDate({
        format: "YYYY-MM-DD",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });

    $("#certificationTime").jeDate({
        format: "YYYY-MM-DD",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });

    $("#kai1").jeDate({
        format: "YYYY-MM-DD",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });
    $("#kai2").jeDate({
        format: "YYYY-MM-DD",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            //color: #3c763d
            //form-control-feedback glyphicon glyphicon-ok
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });
    $("#kai3").jeDate({
        format: "YYYY-MM-DD"
    });
    $("#kai4").jeDate({
        format: "YYYY-MM-DD"
    });
    $("#kai5").jeDate({
        format: "YYYY-MM-DD"
    });
    $("#kai6").jeDate({
        format: "YYYY-MM-DD"
    });
    $("#time3").jeDate({
        format: "YYYY-MM-DD"
    });
    var start = {
        format: 'YYYY-MM-DD',
        minDate: '1910-01-01', //设定最小日期为当前日期
        isinitVal:false,
        maxDate: $.nowDate({DD:0}), //最大日期
        okfun: function(obj){
            end.minDate = obj.val; //开始日选好后，重置结束日的最小日期
            endDates();
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            //color: #3c763d
            //form-control-feedback glyphicon glyphicon-ok
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    };
    var end = {
        format: 'YYYY-MM-DD',
        minDate: $.nowDate({DD:0}), //设定最小日期为当前日期
        maxDate: '2099-12-30', //最大日期
        okfun: function(obj){
            start.maxDate = obj.val; //将结束日的初始值设定为开始日的最大日期
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            //color: #3c763d
            //form-control-feedback glyphicon glyphicon-ok
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    };
//这里是日期联动的关键
    function endDates() {
        //将结束日期的事件改成 false 即可
        end.trigger = false;
        $("#time4").jeDate(end);
    }
    function endDates1() {
        //将结束日期的事件改成 false 即可
        end.trigger = false;
        $("#time41").jeDate(end);
    }
    $('#time5').jeDate(start);
    $('#time4').jeDate(end);

    $("#time51").jeDate(start);
    $("#time41").jeDate(end);


    var start1 = {
        format: 'YYYY-MM-DD hh:mm:ss',
        minDate: '2000-01-01 00:00:00', //设定最小日期为当前日期
        isinitVal:false,
        maxDate: $.nowDate({DD:0}), //最大日期
        okfun: function(obj){
            end.minDate = obj.val; //开始日选好后，重置结束日的最小日期
            endDates();
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            //color: #3c763d
            //form-control-feedback glyphicon glyphicon-ok
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    };
    var end1 = {
        format: 'YYYY-MM-DD hh:mm:ss',
        minDate: $.nowDate({DD:0}), //设定最小日期为当前日期
        maxDate: '2099-12-30 00:00:00', //最大日期
        okfun: function(obj){
            start.maxDate = obj.val; //将结束日的初始值设定为开始日的最大日期
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            //color: #3c763d
            //form-control-feedback glyphicon glyphicon-ok
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    };
//这里是日期联动的关键
    function endDates2() {
        //将结束日期的事件改成 false 即可
        end.trigger = false;
        $("#time2").jeDate(end);
    }
    $('#time1').jeDate(start1);
    $('#time2').jeDate(end1);

    $("#birthday").jeDate({
        format: "YYYY-MM-DD",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });

    $("#marryDate").jeDate({
        format: "YYYY-MM-DD",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            //color: #3c763d
            //form-control-feedback glyphicon glyphicon-ok
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });


    $("#sDate").jeDate({
        format: "YYYY",
        range:" ~ "
    });
    $("#test02").jeDate({
        format: "YYYY-MM-DD hh:mm:ss"
    });
    $("#test03").jeDate({
        format: "YYYY-MM-DD hh:mm:ss",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });
    $("#test04").jeDate({
        format: "YYYY-MM-DD hh:mm:ss",
        okfun: function (obj) {
            $(obj.elem[0]).attr("value", obj.val);
            $(obj.elem[0]).next().next().hide();
            $(obj.elem[0]).css("border", "1px solid #3c763d")
            $(obj.elem[0]).parent().prev().css("color", "#3c763d");
            //color: #3c763d
            //form-control-feedback glyphicon glyphicon-ok
            $(obj.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-ok").css("color", "#3c763d");
        },
        clearfun: function (elem, val) {
            console.log(elem);
            $(elem.elem[0]).next().next().show();
            $(elem.elem[0]).css("border", "1px solid #a94442")
            $(elem.elem[0]).parent().prev().css("color", "#a94442");
            $(elem.elem[0]).next().attr("class", "form-control-feedback glyphicon glyphicon-remove").css("color", "#a94442");
        }
    });



    $("#test05").jeDate({
        format: "hh:mm:ss"
    });
    $("#test06").jeDate({
        format: "hh:mm:ss"
    });
    //区域范围选择
    // $("#test06").jeDate({
    //     format: "YYYY",
    //     range:" ~ "
    // });
    // $("#test07").jeDate({
    //     format: "YYYY-MM",
    //     range:" To "
    // });
    // $("#test08").jeDate({
    //     format: "YYYY-MM-DD",
    //     range:" 至 "
    // });
    //区域范围双面板选择
    $("#test09").jeDate({
        format: "YYYY",
        multiPane: false,
        range: " ~ "

    });
    $("#test010").jeDate({
        format: "YYYY-MM",
        multiPane: false,
        range: " ~ "

    });
    $("#test011").jeDate({
        format: "DD",
        multiPane: false,
        range: " ~ "

    });
    // $("#test10").jeDate({
    //     format: "YYYY-MM",
    //     multiPane:false,
    //     range:" To "
    // });
    // $("#test11").jeDate({
    //     format: "YYYY-MM-DD",
    //     multiPane:false,
    //     range:" 至 "
    // });
    // //自定义格式选择
    // $("#test12").jeDate({
    //     format: "YYYY年MM月DD日"
    // });
    // $("#test13").jeDate({
    //     format: "MM-DD-YYYY"
    // });
    // $("#test14").jeDate({
    //     format: "DD/MM/YYYY"
    // });
    // //一次绑定多个选择
    // $(".moredate").each(function(){
    //     var mat = $(this).attr("placeholder");
    //     $(this).jeDate({
    //         format: mat
    //     });
    // });
    // //其它功能展示选择
    // $("#test15").jeDate({
    //     format: "YYYY-MM-DD",
    //     isinitVal: true
    // });
    // $("#test16").jeDate({
    //     format: "YYYY-MM-DD",
    //     okfun:function (elem,value) {
    //         alert('你选择的日期是：' + value)
    //     }
    // });
    // $("#test17").jeDate({
    //     format: "YYYY-MM-DD",
    //     toggle:function (elem,value,date) {
    //         alert('你选择的日期是：' + value + '\n\n获得的对象是' + JSON.stringify(date));
    //     }
    // });
    // $("#test18").jeDate({
    //     trigger:"dblclick",
    //     format: "YYYY-MM-DD"
    // });
    // var custom = $("#test19").jeDate({
    //     format: "YYYY-MM-DD"
    // });
    // custom.setValue("2017-09-01");
    // //有效、无效日期限制
    // $("#test20").jeDate({
    //     valiDate:["0[4-7]$,1[1-5]$,2[58]$",true],
    //     format: "YYYY年MM月DD日"
    // });
    // $("#test21").jeDate({
    //     valiDate:["0[4-7]$,1[1-5]$,2[58]$",false],
    //     format: "YYYY年MM月DD日"
    // });
    // $("#test22").jeDate({
    //     valiDate:["1$,3$,6$,9$",true],
    //     format: "YYYY年MM月DD日"
    // });
    // $("#test23").jeDate({
    //     valiDate:["1$,3$,6$,9$",false],
    //     format: "YYYY年MM月DD日"
    // });
    // $("#test24").jeDate({
    //     valiDate:["%1,%3,%6,%9,%12,%15,%25",true],
    //     format: "YYYY年MM月DD日"
    // });
    // $("#test25").jeDate({
    //     valiDate:["%1,%3,%6,%9,%12,%15,%25",false],
    //     format: "YYYY年MM月DD日"
    // });
    //直接展示日历
    // $("#show01").jeDate({
    //     isShow:false,
    //     format: "YYYY-MM-DD"
    // });
    // $("#show02").jeDate({
    //     isShow:false,
    //     format: "YYYY-MM"
    // });
    // $("#show03").jeDate({
    //     isShow:false,
    //     format: "YYYY"
    // });
    // $("#show04").jeDate({
    //     isShow:false,
    //     format: "hh:mm:ss"
    // });




});